<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <script src="/script/jquery-3.3.1.min.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script type="text/javascript" src="/script/admin/inviteImg/request.js"></script>
</head>
<body>
<div id="app">
    <div>
        <el-table
                :data="tableData"
                border
                v-loading="tableLoading"
                style="width: 100%">
            <el-table-column
                    prop="id"
                    align="center"
                    label="ID">
            </el-table-column>
            <el-table-column
                    prop="imgType"
                    align="center"
                    label="类型">
                <template slot-scope="scope">
                    <p v-if="scope.row.imgType == 'GOODS'">爆款好物群</p>
                    <p v-if="scope.row.imgType == 'COUPON'">撸单群</p>
                </template>
            </el-table-column>
            <el-table-column
                    prop="description"
                    align="center"
                    label="描述">
            </el-table-column>
            <el-table-column
                    prop="url"
                    align="center"
                    label="图片">
                <template slot-scope="scope">
                    <el-image
                            style="width: 100px; height: 100px"
                            :src="scope.row.url"></el-image>
                </template>
            </el-table-column>
            <el-table-column
                    label="操作"  align="center">
                <template slot-scope="scope">
                    <el-button size="small" @click="editView(scope.row.id)">
                        编辑</el-button>
                </template>
            </el-table-column>
        </el-table>
        <div class="pagination-box" >
            <el-pagination background @current-change="queryData" :current-page="pagination.page" :page-size="pagination.size" layout="total, prev, pager, next, jumper" :total="pagination.count"></el-pagination>
        </div>
    </div>
</div>
</body>
<!-- import Vue before Element -->
<script src="https://unpkg.com/vue@2/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script>
    new Vue({
        el: '#app',
        data: function() {
            return {
                query:{
                    title:''
                },
                pagination: {
                    page:  1,
                    size:  10,
                    count: 0
                },
                tableData:[],
                tableLoading:false,
            }
        },
        methods: {
            queryData(page) {
                this.pagination.page = page || 1
                this.getData();
            },
            getData() {
                var prams = {
                    page: this.pagination.page,
                    size: this.pagination.size,
                    ...this.query
                }
                page(prams).then(res => {
                    this.tableData = res.data;
                    this.pagination.count = res.count
                })
            },
            editView(id) {
                var url = "/admin/inviteImg/"+id+"/view";
                $(this).attr("data-url",url);
                parent.addTab($(this))
            },
        },
        computed:{
        },
        created () {
            this.getData();
        }
    })
</script>
</html>


